package com.zhiyou100.blog.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	private static SimpleDateFormat sdf;
	static{
		sdf=new SimpleDateFormat("yyyy-MM-dd");
	}
     //时间转化为字符串
	public static String date2Str(Date d){
		return sdf.format(d);
	}
	 //字符串转化为时间
	public static Date str2Date(String s){
		try {
			return sdf.parse(s);
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
}
